|
@@ -21,12 +21,12 @@ import java.util.Random;
|
|
|
|
|
|
/*
|
|
|
* <Title> IntegralShoppingMallController </Title>
|
|
|
- * <Description> 油站积分商城 </Description>
|
|
|
+ * <Description> 油站积分商城控制层 </Description>
|
|
|
* @Author JK
|
|
|
* @Date 2021年2月24日
|
|
|
*/
|
|
|
@Controller
|
|
|
-@RequestMapping("/api")
|
|
|
+@RequestMapping("/demo")
|
|
|
public class IntegralShoppingMallController {
|
|
|
private static Logger logger =(Logger) LoggerFactory.getLogger(IntegralShoppingMallController.class);
|
|
|
@Resource
|
|
@@ -37,6 +37,8 @@ public class IntegralShoppingMallController {
|
|
|
private CustomerPointsService customerPointsService;
|
|
|
@Resource
|
|
|
private StationService stationService;
|
|
|
+ @Resource
|
|
|
+ private CustomerPointsRecordService customerPointsRecordService;
|
|
|
|
|
|
//获取油站积分商品信息
|
|
|
@RequestMapping(value = "/getIntegralWaresInfoList", method = RequestMethod.GET)
|
|
@@ -64,9 +66,14 @@ public class IntegralShoppingMallController {
|
|
|
Gson gson =new Gson();
|
|
|
//返回结果集
|
|
|
ResultData resultData = null;
|
|
|
- IntegralOrder integralOrder = new IntegralOrder();
|
|
|
+ IntegralOrder integralOrder = new IntegralOrder(); //积分订单
|
|
|
+ IntegralWares integralWares = new IntegralWares(); //积分商品表
|
|
|
+ CustomerPoints customerPoints = new CustomerPoints(); //客户积分表
|
|
|
+ CustomerPointsRecord customerPointsRecord = new CustomerPointsRecord(); //客户积分记录
|
|
|
+
|
|
|
if(StringUtils.isNotBlank(request.getCustomerName())){
|
|
|
integralOrder.setCustomerName(request.getCustomerName());
|
|
|
+ customerPointsRecord.setCustomerName(request.getCustomerName());
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(request.getWaresName())){
|
|
|
integralOrder.setWaresName(request.getWaresName());
|
|
@@ -76,15 +83,20 @@ public class IntegralShoppingMallController {
|
|
|
}
|
|
|
if(request.getStationId() != null){
|
|
|
integralOrder.setStationId(request.getStationId());
|
|
|
+ customerPointsRecord.setStationId(request.getStationId());
|
|
|
}
|
|
|
if(request.getWaresId() !=null){
|
|
|
integralOrder.setWaresId(request.getWaresId());
|
|
|
+ integralWares.setId(request.getWaresId());
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(request.getUnionId())){
|
|
|
integralOrder.setUnionId(request.getUnionId());
|
|
|
+ customerPoints.setUnionId(request.getUnionId());
|
|
|
+ customerPointsRecord.setUnionId(request.getUnionId());
|
|
|
}
|
|
|
if(request.getIntegral() !=null){
|
|
|
integralOrder.setIntegral(request.getIntegral());
|
|
|
+ customerPointsRecord.setIntegral(request.getIntegral());
|
|
|
}
|
|
|
|
|
|
integralOrder.setStatus("1"); //订单状态
|
|
@@ -99,8 +111,6 @@ public class IntegralShoppingMallController {
|
|
|
integralOrder.setExchangeTime(new Date());
|
|
|
|
|
|
//更新用户积分
|
|
|
- CustomerPoints customerPoints = new CustomerPoints();
|
|
|
- customerPoints.setUnionId(request.getUnionId());
|
|
|
CustomerPoints customerPointsInfo = customerPointsService.getCustomerPointsInfo(customerPoints);
|
|
|
if(customerPointsInfo !=null){
|
|
|
//用户剩余积分
|
|
@@ -116,10 +126,9 @@ public class IntegralShoppingMallController {
|
|
|
Map<String, String> m = stationService.getStationAppIdAndAppSecret(request.getStationId());
|
|
|
if(m !=null && m.containsKey("stationName")){
|
|
|
integralOrder.setStationName(m.get("stationName"));
|
|
|
+ customerPointsRecord.setStationName(m.get("stationName"));
|
|
|
}
|
|
|
|
|
|
- IntegralWares integralWares = new IntegralWares();
|
|
|
- integralWares.setId(request.getWaresId());
|
|
|
List<IntegralWares> integralWaresInfoList = integralWaresService.getIntegralWaresInfoList(integralWares);
|
|
|
if(integralWaresInfoList !=null && integralWaresInfoList.size() ==1){
|
|
|
//更新商品已售数量
|
|
@@ -127,6 +136,12 @@ public class IntegralShoppingMallController {
|
|
|
integralWaresService.updateIntegralWaresInfo(integralWares);
|
|
|
}
|
|
|
|
|
|
+ //插入客户记录表
|
|
|
+ customerPointsRecord.setRecordType("-"); //客户积分表记录
|
|
|
+ customerPointsRecord.setCreateTime(new Date());
|
|
|
+ customerPointsRecordService.insertCustomerPointsInfo(customerPointsRecord);
|
|
|
+
|
|
|
+
|
|
|
boolean b = integralOrderService.insertIntegralOrder(integralOrder);
|
|
|
if (b){
|
|
|
resultData=ResultData.success(CodeMsg.SUCCESS);
|
|
@@ -136,7 +151,7 @@ public class IntegralShoppingMallController {
|
|
|
return gson.toJson(resultData);
|
|
|
}
|
|
|
|
|
|
- //获取用户订单列表
|
|
|
+ //获取用户积分订单列表
|
|
|
@RequestMapping(value = "/getUserIntegralOrderList", method = RequestMethod.GET)
|
|
|
@ResponseBody
|
|
|
public String getUserIntegralOrderList(@RequestParam String unionId){
|
|
@@ -146,6 +161,7 @@ public class IntegralShoppingMallController {
|
|
|
if(unionId !=null){
|
|
|
IntegralOrder integralOrder = new IntegralOrder();
|
|
|
integralOrder.setUnionId(unionId);
|
|
|
+ //integralOrder.setStationId(stationId);
|
|
|
List<IntegralOrder> integralOrderList = integralOrderService.getUserIntegralOrderList(integralOrder);
|
|
|
resultData=ResultData.success(integralOrderList);
|
|
|
}else {
|
|
@@ -154,6 +170,41 @@ public class IntegralShoppingMallController {
|
|
|
return gson.toJson(resultData);
|
|
|
}
|
|
|
|
|
|
- //获取客户积分
|
|
|
+ //获取客户积分信息
|
|
|
+ @RequestMapping(value = "/getCustomerPointsInfo", method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public String getCustomerPointsInfo(@RequestParam("unionId") String unionId){
|
|
|
+ Gson gson =new Gson();
|
|
|
+ //返回结果集
|
|
|
+ ResultData resultData = null;
|
|
|
+ if(unionId !=null){
|
|
|
+ CustomerPoints customerPoints =new CustomerPoints();
|
|
|
+ customerPoints.setUnionId(unionId);
|
|
|
+ //customerPoints.setStationId(stationId);
|
|
|
+ CustomerPoints customerPointsInfo = customerPointsService.getCustomerPointsInfo(customerPoints);
|
|
|
+ resultData=ResultData.success(customerPointsInfo);
|
|
|
+ }else {
|
|
|
+ resultData=ResultData.success(CodeMsg.REQUEST_FAIL);
|
|
|
+ }
|
|
|
+ return gson.toJson(resultData);
|
|
|
+ }
|
|
|
|
|
|
+ //获取客户积分记录信息
|
|
|
+ @RequestMapping(value = "/getCustomerPointsRecordList", method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public String getCustomerPointsRecordList(@RequestParam("unionId") String unionId){
|
|
|
+ Gson gson =new Gson();
|
|
|
+ //返回结果集
|
|
|
+ ResultData resultData = null;
|
|
|
+ if(unionId !=null){
|
|
|
+ CustomerPointsRecord customerPointsRecord =new CustomerPointsRecord();
|
|
|
+ customerPointsRecord.setUnionId(unionId);
|
|
|
+ //customerPointsRecord.setStationId(stationId);
|
|
|
+ List<CustomerPointsRecord> customerPointsRecordList = customerPointsRecordService.getCustomerPointsRecordList(customerPointsRecord);
|
|
|
+ resultData=ResultData.success(customerPointsRecordList);
|
|
|
+ }else {
|
|
|
+ resultData=ResultData.success(CodeMsg.REQUEST_FAIL);
|
|
|
+ }
|
|
|
+ return gson.toJson(resultData);
|
|
|
+ }
|
|
|
}
|