From bff8c0bc7a21a9448f842485397438b75e8f1a48 Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Thu, 9 Jun 2022 14:39:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6=E8=AF=9D=E8=B4=B9=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ApiMerchantsController.java | 16 ++++ .../bweb/controller/ApiProductController.java | 91 ++++++++++++++++++- .../hai/dao/ApiProductConfigMapperExt.java | 42 ++++++++- .../com/hai/model/ApiProductConfigModel.java | 60 ++++++++++++ .../com/hai/service/ApiMerchantsService.java | 15 +++ .../com/hai/service/ApiProductService.java | 21 +++++ .../service/impl/ApiMerchantsServiceImpl.java | 11 +++ .../service/impl/ApiProductServiceImpl.java | 13 +++ .../resources/dev/commonConfig.properties | 8 +- 9 files changed, 267 insertions(+), 10 deletions(-) create mode 100644 hai-service/src/main/java/com/hai/model/ApiProductConfigModel.java diff --git a/hai-bweb/src/main/java/com/bweb/controller/ApiMerchantsController.java b/hai-bweb/src/main/java/com/bweb/controller/ApiMerchantsController.java index 5248a48f..096f3fe6 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/ApiMerchantsController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/ApiMerchantsController.java @@ -11,6 +11,7 @@ import com.hai.common.security.UserCenter; import com.hai.common.utils.*; import com.hai.entity.ApiMerchants; import com.hai.entity.ApiProduct; +import com.hai.entity.ApiProductConfig; import com.hai.enum_type.ApiAmountRecordTypeEnum; import com.hai.enum_type.CompanyAmountSourceTypeEnum; import com.hai.model.HighMerchantModel; @@ -278,4 +279,19 @@ public class ApiMerchantsController { } } + @RequestMapping(value = "/getListMerchProduct", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询商户产品") + public ResponseData getListMerchProduct(@RequestParam(value = "merchantId", required = true) Long merchantId) { + try { + + return ResponseMsgUtil.success(apiMerchantsService.getListMerchProduct(merchantId)); + + } catch (Exception e) { + log.error("ApiMerchantsController --> findById() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + } diff --git a/hai-bweb/src/main/java/com/bweb/controller/ApiProductController.java b/hai-bweb/src/main/java/com/bweb/controller/ApiProductController.java index 7d1f5d3c..0f09bf86 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/ApiProductController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/ApiProductController.java @@ -10,10 +10,7 @@ import com.hai.common.security.SessionObject; import com.hai.common.security.UserCenter; import com.hai.common.utils.PageUtil; import com.hai.common.utils.ResponseMsgUtil; -import com.hai.entity.ApiProduct; -import com.hai.entity.BsOperationLog; -import com.hai.entity.HighAgent; -import com.hai.entity.OutRechargePrice; +import com.hai.entity.*; import com.hai.model.OutRechargePriceModel; import com.hai.model.ResponseData; import com.hai.model.UserInfoModel; @@ -236,7 +233,7 @@ public class ApiProductController { if (object == null || object.getJSONArray("productIds") == null || - object.getInteger("discount") == null || + object.getBigDecimal("discount") == null || object.getLong("merchantsId") == null ) { log.error("ApiProductController -> configApiProduct() error!"); @@ -253,4 +250,88 @@ public class ApiProductController { } } + + @RequestMapping(value = "/editConfigApiProductByStatus", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "修改商户产品状态") + public ResponseData editConfigApiProductByStatus(@RequestBody JSONObject object, HttpServletRequest request) { + try { + + if (object == null || + object.getInteger("status") == null || + object.getInteger("id") == null + ) { + log.error("ApiProductController -> configApiProduct() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + + ApiProductConfig apiProductConfig = apiProductService.findProductConfigById(object.getLong("id")); + + apiProductConfig.setStatus(object.getInteger("status")); + apiProductConfig.setOperatorName(userInfoModel.getSecUser().getUserName()); + apiProductConfig.setOperatorId(userInfoModel.getSecUser().getId()); + apiProductService.updateConfigApiProduct(apiProductConfig); + + return ResponseMsgUtil.success("修改成功"); + + } catch (Exception e) { + log.error("ApiProductController --> editPriceStatus() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + + @RequestMapping(value = "/updateConfigApiProduct", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "修改配置产品") + public ResponseData updateConfigApiProduct(@RequestBody JSONObject object) { + try { + + if (object == null || + object.getBigDecimal("discount") == null || + object.getLong("id") == null + ) { + log.error("ApiProductController -> configApiProduct() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + ApiProductConfig apiProductConfig = apiProductService.findProductConfigById(object.getLong("id")); + + ApiProduct apiProduct = apiProductService.findById(apiProductConfig.getProductId()); + + if (apiProductConfig.getStatus() == 101) { + log.error("ApiProductController -> configApiProduct() error!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前状态错误"); + } + + apiProductConfig.setDiscount(object.getBigDecimal("discount")); + apiProductConfig.setDiscountPrice(apiProduct.getRechargePrice().multiply(object.getBigDecimal("discount")).divide(new BigDecimal(100))); + + apiProductService.updateConfigApiProduct(apiProductConfig); + + return ResponseMsgUtil.success("修改成功"); + + } catch (Exception e) { + log.error("ApiProductController --> insertPrice() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/findConfigProduct", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询配置产品") + public ResponseData findConfigProduct(@RequestParam(value = "id", required = true) Long id) { + try { + + return ResponseMsgUtil.success(apiProductService.findProductConfigById(id)); + + } catch (Exception e) { + log.error("ApiMerchantsController --> findById() error!", e); + return ResponseMsgUtil.exception(e); + } + } + } diff --git a/hai-service/src/main/java/com/hai/dao/ApiProductConfigMapperExt.java b/hai-service/src/main/java/com/hai/dao/ApiProductConfigMapperExt.java index c25eb4aa..ab7ee319 100644 --- a/hai-service/src/main/java/com/hai/dao/ApiProductConfigMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/ApiProductConfigMapperExt.java @@ -1,7 +1,47 @@ package com.hai.dao; +import com.hai.model.ApiProductConfigModel; +import com.hai.model.OutUserOrderModel; +import org.apache.ibatis.annotations.Result; +import org.apache.ibatis.annotations.Results; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.type.JdbcType; + +import java.util.List; + /** * mapper扩展类 */ public interface ApiProductConfigMapperExt { -} \ No newline at end of file + + @Select(value = { + "" + }) + @Results({ + @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="recharge_type", property="rechargeType", jdbcType=JdbcType.INTEGER), + @Result(column="recharge_platform", property="rechargePlatform", jdbcType=JdbcType.VARCHAR), + @Result(column="phone_recharge_type", property="phoneRechargeType", jdbcType=JdbcType.INTEGER), + @Result(column="operator_type", property="operatorType", jdbcType=JdbcType.INTEGER), + @Result(column="recharge_price", property="rechargePrice", jdbcType=JdbcType.DECIMAL), + @Result(column="product_id", property="productId", jdbcType=JdbcType.BIGINT), + @Result(column="api_config_product_id", property="apiConfigProductId", jdbcType=JdbcType.BIGINT), + @Result(column="sort", property="sort", jdbcType=JdbcType.INTEGER), + @Result(column="discount", property="discount", jdbcType=JdbcType.DECIMAL), + @Result(column="discount_price", property="discountPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="operator_id", property="operatorId", jdbcType=JdbcType.BIGINT), + @Result(column="operator_name", property="operatorName", jdbcType=JdbcType.VARCHAR), + @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), + @Result(column="config_status", property="configStatus", jdbcType=JdbcType.INTEGER), + @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR) + }) + List getListMerchProduct(Long merchantsId); + +} diff --git a/hai-service/src/main/java/com/hai/model/ApiProductConfigModel.java b/hai-service/src/main/java/com/hai/model/ApiProductConfigModel.java new file mode 100644 index 00000000..4d44ab30 --- /dev/null +++ b/hai-service/src/main/java/com/hai/model/ApiProductConfigModel.java @@ -0,0 +1,60 @@ +package com.hai.model; + +import com.hai.entity.ApiProduct; +import com.hai.entity.ApiProductConfig; + +import java.math.BigDecimal; + +public class ApiProductConfigModel extends ApiProduct { + /** + * 折扣比例 + */ + private BigDecimal discount; + + /** + * 折扣价格 + */ + private BigDecimal discountPrice; + + /** + * 主键 + */ + private Long apiConfigProductId; + + /** + * 101 正常 102 下架 100 删除 + */ + private Integer configStatus; + + public Integer getConfigStatus() { + return configStatus; + } + + public void setConfigStatus(Integer configStatus) { + this.configStatus = configStatus; + } + + public Long getApiConfigProductId() { + return apiConfigProductId; + } + + public void setApiConfigProductId(Long apiConfigProductId) { + this.apiConfigProductId = apiConfigProductId; + } + + public BigDecimal getDiscount() { + return discount; + } + + public void setDiscount(BigDecimal discount) { + this.discount = discount; + } + + public BigDecimal getDiscountPrice() { + return discountPrice; + } + + public void setDiscountPrice(BigDecimal discountPrice) { + this.discountPrice = discountPrice; + } +} diff --git a/hai-service/src/main/java/com/hai/service/ApiMerchantsService.java b/hai-service/src/main/java/com/hai/service/ApiMerchantsService.java index 11db0ffc..167fbd74 100644 --- a/hai-service/src/main/java/com/hai/service/ApiMerchantsService.java +++ b/hai-service/src/main/java/com/hai/service/ApiMerchantsService.java @@ -3,6 +3,8 @@ package com.hai.service; import com.alibaba.fastjson.JSONObject; import com.hai.entity.ApiAmountRecord; import com.hai.entity.ApiMerchants; +import com.hai.entity.ApiProductConfig; +import com.hai.model.ApiProductConfigModel; import java.math.BigDecimal; import java.util.List; @@ -77,5 +79,18 @@ public interface ApiMerchantsService { */ List getMerchRechargeData(Long merchantId); + /** + * @Author Sum1Dream + * @name getListMerchProduct.java + * @Description // 查询商户配置产品 + * @Date 10:10 2022/6/9 + * @Param [java.lang.Long] + * @return java.util.List + */ + List getListMerchProduct(Long merchantId); + + + + } diff --git a/hai-service/src/main/java/com/hai/service/ApiProductService.java b/hai-service/src/main/java/com/hai/service/ApiProductService.java index 702073ce..f3cdc626 100644 --- a/hai-service/src/main/java/com/hai/service/ApiProductService.java +++ b/hai-service/src/main/java/com/hai/service/ApiProductService.java @@ -2,6 +2,7 @@ package com.hai.service; import com.alibaba.fastjson.JSONObject; import com.hai.entity.ApiProduct; +import com.hai.entity.ApiProductConfig; import io.swagger.annotations.Api; import java.util.List; @@ -65,4 +66,24 @@ public interface ApiProductService { * @return void */ void configApiProduct(JSONObject object); + + /** + * @Author Sum1Dream + * @name updateConfigApiProduct.java + * @Description // 修改配置产品 + * @Date 11:17 2022/6/9 + * @Param [com.alibaba.fastjson.JSONObject] + * @return void + */ + void updateConfigApiProduct(ApiProductConfig apiProductConfig); + + /** + * @Author Sum1Dream + * @name findProductConfigById.java + * @Description // 查询配置产品 + * @Date 11:02 2022/6/9 + * @Param [java.lang.Long] + * @return com.hai.entity.ApiProductConfig + */ + ApiProductConfig findProductConfigById(Long id); } diff --git a/hai-service/src/main/java/com/hai/service/impl/ApiMerchantsServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/ApiMerchantsServiceImpl.java index 9906d362..74eb336c 100644 --- a/hai-service/src/main/java/com/hai/service/impl/ApiMerchantsServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/ApiMerchantsServiceImpl.java @@ -7,7 +7,9 @@ import com.hai.common.security.UserCenter; import com.hai.common.utils.RedisUtil; import com.hai.dao.ApiAmountRecordMapper; import com.hai.dao.ApiMerchantsMapper; +import com.hai.dao.ApiProductConfigMapper; import com.hai.entity.*; +import com.hai.model.ApiProductConfigModel; import com.hai.model.UserInfoModel; import com.hai.service.ApiMerchantsService; import org.apache.commons.collections4.MapUtils; @@ -37,6 +39,9 @@ public class ApiMerchantsServiceImpl implements ApiMerchantsService { @Resource private ApiAmountRecordMapper apiAmountRecordMapper; + @Resource + private ApiProductConfigMapper apiProductConfigMapper; + @Override public void insertApiMerchants(ApiMerchants apiMerchants) { apiMerchantsMapper.insert(apiMerchants); @@ -134,4 +139,10 @@ public class ApiMerchantsServiceImpl implements ApiMerchantsService { example.createCriteria().andMchIdEqualTo(apiMerchants.getMchId()); return apiAmountRecordMapper.selectByExample(example); } + + @Override + public List getListMerchProduct(Long merchantId) { + return apiProductConfigMapper.getListMerchProduct(merchantId); + } + } diff --git a/hai-service/src/main/java/com/hai/service/impl/ApiProductServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/ApiProductServiceImpl.java index b28ff8a8..1efd8890 100644 --- a/hai-service/src/main/java/com/hai/service/impl/ApiProductServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/ApiProductServiceImpl.java @@ -112,7 +112,9 @@ public class ApiProductServiceImpl implements ApiProductService { // 转换产品数组 JSONArray productsArray = object.getJSONArray("productIds"); ApiProductConfig apiProductConfig; + ApiProduct apiProduct; for (Object productId : productsArray) { + apiProduct = apiProductMapper.selectByPrimaryKey(Long.valueOf(productId.toString())); apiProductConfig = new ApiProductConfig(); apiProductConfig.setProductId(Long.valueOf(productId.toString())); apiProductConfig.setCreateTime(new Date()); @@ -120,9 +122,20 @@ public class ApiProductServiceImpl implements ApiProductService { apiProductConfig.setOperatorName(sessionModel.getSecUser().getUserName()); apiProductConfig.setStatus(101); apiProductConfig.setDiscount(object.getBigDecimal("discount")); + apiProductConfig.setDiscountPrice(apiProduct.getRechargePrice().multiply(object.getBigDecimal("discount")).divide(new BigDecimal(100))); apiProductConfig.setMerchantsId(object.getLong("merchantsId")); apiProductConfig.setUpdateTime(new Date()); apiProductConfigMapper.insert(apiProductConfig); } } + + @Override + public ApiProductConfig findProductConfigById(Long id) { + return apiProductConfigMapper.selectByPrimaryKey(id); + } + + @Override + public void updateConfigApiProduct(ApiProductConfig apiProductConfig) { + apiProductConfigMapper.updateByPrimaryKey(apiProductConfig); + } } diff --git a/hai-service/src/main/resources/dev/commonConfig.properties b/hai-service/src/main/resources/dev/commonConfig.properties index e1b6f8d6..01d060e7 100644 --- a/hai-service/src/main/resources/dev/commonConfig.properties +++ b/hai-service/src/main/resources/dev/commonConfig.properties @@ -14,10 +14,10 @@ qinzhuSecret=ktxb49sh2jfhgn8g qianzhuOrderNotify=https://hsg.dctpay.com/crest/qianzhu/orderNotify # ??????? -huiliantongUrl=https://gzapi.deepermobile.com.cn -huiliantongAppNo=guizhouhuilt -huiliantongAppkey=e0ja2Ex%2BmQ2hIPF6x%2BHA%3D -huiliantongAppsecret=52662415DDCE55C7BA34223BCF53877A +huiliantongUrl=https://gzapitest.deepermobile.com.cn:441 +huiliantongAppNo=guizhouhltcs +huiliantongAppkey=g%2BNnjR54YSUWM2iKg%2Fd82A9x9hg2kYV7 +huiliantongAppsecret=FA28E95ACABFA4B2B8E25857437B07F1 # ???????? HuiLianTongUnionCardUrl=http://hltgz.com:4010/api/v2/execute.json