parent
23b97087ec
commit
a178adec42
@ -0,0 +1,101 @@ |
|||||||
|
package com.cweb.controller.output; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
import com.hfkj.api.ApiMerService; |
||||||
|
import com.hfkj.common.exception.ErrorCode; |
||||||
|
import com.hfkj.common.exception.ErrorHelp; |
||||||
|
import com.hfkj.common.exception.SysCode; |
||||||
|
import com.hfkj.common.security.UserCenter; |
||||||
|
import com.hfkj.common.utils.ResponseMsgUtil; |
||||||
|
import com.hfkj.common.utils.SignatureUtil; |
||||||
|
import com.hfkj.entity.*; |
||||||
|
import com.hfkj.model.ResponseData; |
||||||
|
import com.hfkj.model.UserSessionObject; |
||||||
|
import com.hfkj.service.SecDictionaryService; |
||||||
|
import com.hfkj.service.discount.CouponDiscountPackageService; |
||||||
|
import com.hfkj.service.discount.CouponDiscountService; |
||||||
|
import com.hfkj.service.discount.CouponDiscountUserRelService; |
||||||
|
import com.hfkj.service.user.BsUserService; |
||||||
|
import com.hfkj.sysenum.UserLoginPlatform; |
||||||
|
import io.swagger.annotations.Api; |
||||||
|
import io.swagger.annotations.ApiOperation; |
||||||
|
import org.apache.commons.lang3.StringUtils; |
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
import org.springframework.stereotype.Controller; |
||||||
|
import org.springframework.web.bind.annotation.*; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import java.util.*; |
||||||
|
import java.util.concurrent.ConcurrentHashMap; |
||||||
|
import java.util.function.Function; |
||||||
|
import java.util.function.Predicate; |
||||||
|
import java.util.stream.Collectors; |
||||||
|
|
||||||
|
@Controller |
||||||
|
@RequestMapping(value="/output") |
||||||
|
@Api(value="输出外部接口") |
||||||
|
public class OutputController { |
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(OutputController.class); |
||||||
|
|
||||||
|
@Resource |
||||||
|
private ApiMerService apiMerService; |
||||||
|
|
||||||
|
@Resource |
||||||
|
private CouponDiscountUserRelService discountUserRelService; |
||||||
|
@Resource |
||||||
|
private BsUserService bsUserService; |
||||||
|
|
||||||
|
@RequestMapping(value = "/getListUserDiscount", method = RequestMethod.POST) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "获取用户优惠券列表") |
||||||
|
public ResponseData getListUserDiscount(@RequestBody JSONObject body) { |
||||||
|
try { |
||||||
|
|
||||||
|
if (body == null |
||||||
|
|| StringUtils.isBlank(body.getString("status")) |
||||||
|
|| StringUtils.isBlank(body.getString("phone")) |
||||||
|
|| StringUtils.isBlank(body.getString("sign")) |
||||||
|
|| StringUtils.isBlank(body.getString("appid")) |
||||||
|
) { |
||||||
|
log.error("LoginController --> phone() error!", "请求参数校验失败"); |
||||||
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||||
|
} |
||||||
|
|
||||||
|
// 查询api商户信息
|
||||||
|
ApiMer apiMer = apiMerService.queryDetail(body.getString("appid")); |
||||||
|
|
||||||
|
Map<String , Object> map = new HashMap<>(); |
||||||
|
map.put("appid" , body.getString("appid")); |
||||||
|
map.put("phone" , body.getString("phone")); |
||||||
|
map.put("status" , body.getString("status")); |
||||||
|
String sign = SignatureUtil.createSign(map , apiMer.getAppSecret()); |
||||||
|
if (!body.getString("sign").equals(sign)) { |
||||||
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "签名校验失败!"); |
||||||
|
} |
||||||
|
|
||||||
|
// 查询用户信息
|
||||||
|
BsUser user = bsUserService.getUser(body.getString("phone")); |
||||||
|
|
||||||
|
if (user == null) { |
||||||
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "用户不存在!"); |
||||||
|
} |
||||||
|
|
||||||
|
Map<String, Object> mapPost = new HashMap<>(); |
||||||
|
|
||||||
|
mapPost.put("userId", user.getId()); |
||||||
|
mapPost.put("status", body.getInteger("status")); |
||||||
|
|
||||||
|
return ResponseMsgUtil.success(discountUserRelService.getList(mapPost)); |
||||||
|
|
||||||
|
} catch (Exception e) { |
||||||
|
log.error("GoodsDetailController --> getListUser() error!", e); |
||||||
|
return ResponseMsgUtil.exception(e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,14 @@ |
|||||||
|
package com.hfkj.model.discount; |
||||||
|
|
||||||
|
import com.hfkj.entity.CouponDiscountUserRel; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class CouponDiscountUserRelModel extends CouponDiscountUserRel { |
||||||
|
|
||||||
|
/** |
||||||
|
* 优惠券来源 |
||||||
|
*/ |
||||||
|
private Integer source; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,4 @@ |
|||||||
|
package com.hfkj.service.goods; |
||||||
|
|
||||||
|
public interface GoodPresentService { |
||||||
|
} |
Loading…
Reference in new issue