Merge branch 'api-dev' of http://139.159.177.244:3000/hurui/hai-server into api-dev
commit
a9cc50fe56
@ -0,0 +1,166 @@ |
||||
package com.bweb.controller; |
||||
|
||||
import com.github.pagehelper.PageHelper; |
||||
import com.github.pagehelper.PageInfo; |
||||
import com.hai.common.exception.ErrorCode; |
||||
import com.hai.common.exception.ErrorHelp; |
||||
import com.hai.common.exception.SysCode; |
||||
import com.hai.common.security.SessionObject; |
||||
import com.hai.common.security.UserCenter; |
||||
import com.hai.common.utils.*; |
||||
import com.hai.entity.ApiMemberProduct; |
||||
import com.hai.entity.ApiMerchants; |
||||
import com.hai.model.ResponseData; |
||||
import com.hai.model.UserInfoModel; |
||||
import com.hai.service.ApiMemberProductService; |
||||
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.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.math.BigDecimal; |
||||
import java.util.Date; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@Controller |
||||
@RequestMapping(value = "/apiMemberProduct") |
||||
@Api(value = "api商户") |
||||
public class ApiMemberProductController { |
||||
|
||||
Logger log = LoggerFactory.getLogger(ApiMemberProductController.class); |
||||
|
||||
@Resource |
||||
private ApiMemberProductService apiMemberProductService; |
||||
|
||||
@Autowired |
||||
private UserCenter userCenter; |
||||
|
||||
@Resource |
||||
private RedisUtil redisUtil; |
||||
|
||||
|
||||
@RequestMapping(value = "/getListApiMemberProduct", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询产品列表") |
||||
public ResponseData getListApiMemberProduct( |
||||
@RequestParam(value = "name", required = false) String name, |
||||
@RequestParam(value = "typeId", required = false) Integer typeId, |
||||
@RequestParam(value = "brandId", required = false) String brandId, |
||||
@RequestParam(name = "pageNum", required = true) Integer pageNum, |
||||
@RequestParam(name = "pageSize", required = true) Integer pageSize |
||||
) { |
||||
try { |
||||
|
||||
Map<String, Object> map = new HashMap<>(); |
||||
|
||||
map.put("name", name); |
||||
map.put("typeId", typeId); |
||||
map.put("brandId", brandId); |
||||
|
||||
PageHelper.startPage(pageNum,pageSize); |
||||
|
||||
List<ApiMemberProduct> list = apiMemberProductService.getListApiMemberProduct(map); |
||||
return ResponseMsgUtil.success(new PageInfo<>(list)); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("ApiMerchantsController --> getListUser() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
|
||||
@RequestMapping(value="/insertMemberProduct",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "新增产品") |
||||
public ResponseData insertMemberProduct(@RequestBody ApiMemberProduct apiMemberProduct, HttpServletRequest request) { |
||||
try { |
||||
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); |
||||
if (userInfoModel.getBsCompany() == null) { |
||||
log.error("HighMerchantController -> updateMerchant() error!","该主角色没有权限"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, ""); |
||||
} |
||||
|
||||
if (StringUtils.isBlank(apiMemberProduct.getName()) || |
||||
apiMemberProduct.getTypeId() == null || |
||||
StringUtils.isBlank(apiMemberProduct.getProductId()) || |
||||
apiMemberProduct.getBrandId() == null || |
||||
apiMemberProduct.getPrice() == null ) { |
||||
log.error("ApiMemberProductController -> insertMemberProduct() error!","参数错误"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
apiMemberProduct.setCreateTime(new Date()); |
||||
apiMemberProduct.setUpdateTime(new Date()); |
||||
apiMemberProduct.setOperatorId(userInfoModel.getSecUser().getId()); |
||||
apiMemberProduct.setOperatorName(userInfoModel.getSecUser().getUserName()); |
||||
apiMemberProduct.setStatus(102); |
||||
apiMemberProductService.insertApiMemberProduct(apiMemberProduct); |
||||
|
||||
return ResponseMsgUtil.success("新增成功"); |
||||
} catch (Exception e) { |
||||
log.error("ApiMerchantsController -> insertMerchant() error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/updateMemberProduct",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "修改产品") |
||||
public ResponseData updateMemberProduct(@RequestBody ApiMemberProduct apiMemberProduct, HttpServletRequest request) { |
||||
try { |
||||
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); |
||||
if (userInfoModel.getBsCompany() == null) { |
||||
log.error("HighMerchantController -> updateMerchant() error!","该主角色没有权限"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, ""); |
||||
} |
||||
|
||||
if (StringUtils.isBlank(apiMemberProduct.getName()) || |
||||
apiMemberProduct.getId() == null || |
||||
apiMemberProduct.getTypeId() == null || |
||||
StringUtils.isBlank(apiMemberProduct.getProductId()) || |
||||
apiMemberProduct.getBrandId() == null || |
||||
apiMemberProduct.getPrice() == null ) { |
||||
log.error("ApiMemberProductController -> insertMemberProduct() error!","参数错误"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
|
||||
apiMemberProduct.setUpdateTime(new Date()); |
||||
apiMemberProduct.setOperatorId(userInfoModel.getSecUser().getId()); |
||||
apiMemberProduct.setOperatorName(userInfoModel.getSecUser().getUserName()); |
||||
apiMemberProduct.setStatus(102); |
||||
apiMemberProductService.updateApiMemberProduct(apiMemberProduct); |
||||
|
||||
return ResponseMsgUtil.success("修改成功"); |
||||
} catch (Exception e) { |
||||
log.error("ApiMerchantsController -> insertMerchant() error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/findById", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "根据id查询详情") |
||||
public ResponseData findById(@RequestParam(value = "id", required = true) Long id) { |
||||
try { |
||||
|
||||
return ResponseMsgUtil.success(apiMemberProductService.findById(id)); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("ApiMerchantsController --> findById() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
|
||||
} |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,253 @@ |
||||
package com.cweb.controller.pay; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.cweb.config.SysConst; |
||||
import com.hai.common.exception.ErrorCode; |
||||
import com.hai.common.exception.ErrorHelp; |
||||
import com.hai.common.exception.SysCode; |
||||
import com.hai.common.pay.WechatPayUtil; |
||||
import com.hai.common.pay.entity.WeChatPayReqInfo; |
||||
import com.hai.common.pay.util.MD5Util; |
||||
import com.hai.common.security.AESEncodeUtil; |
||||
import com.hai.common.security.SessionObject; |
||||
import com.hai.common.security.UserCenter; |
||||
import com.hai.common.utils.MathUtils; |
||||
import com.hai.common.utils.ResponseMsgUtil; |
||||
import com.hai.config.CommonSysConst; |
||||
import com.hai.config.QianZhuConfig; |
||||
import com.hai.config.UnionPayConfig; |
||||
import com.hai.entity.*; |
||||
import com.hai.model.HighUserModel; |
||||
import com.hai.model.ResponseData; |
||||
import com.hai.service.HighOrderService; |
||||
import com.hai.service.HighUserCardService; |
||||
import com.hai.service.HighUserPayPasswordService; |
||||
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.RequestBody; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestMethod; |
||||
import org.springframework.web.bind.annotation.ResponseBody; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.math.BigDecimal; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
import java.util.SortedMap; |
||||
import java.util.concurrent.ThreadLocalRandom; |
||||
|
||||
@Controller |
||||
@RequestMapping(value = "/thirdOrder") |
||||
@Api(value = "第三方订单支付接口") |
||||
public class thirdOrderController { |
||||
|
||||
private static Logger log = LoggerFactory.getLogger(TuanYouController.class); |
||||
|
||||
@Resource |
||||
private UserCenter userCenter; |
||||
|
||||
@Resource |
||||
private HighOrderService highOrderService; |
||||
|
||||
@Resource |
||||
private WechatPayUtil wechatPayUtil; |
||||
|
||||
@Resource |
||||
private HighUserCardService highUserCardService; |
||||
|
||||
@Resource |
||||
private UnionPayConfig unionPayConfig; |
||||
|
||||
@Resource |
||||
private HighUserPayPasswordService highUserPayPasswordService; |
||||
|
||||
@RequestMapping(value="/orderToPayByWx",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "微信订单支付发起支付") |
||||
public ResponseData orderToPayByWx(@RequestBody String reqBodyStr) { |
||||
try { |
||||
if (StringUtils.isBlank(reqBodyStr)) { |
||||
log.error("orderToPay error!", "参数错误"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
JSONObject jsonObject = JSONObject.parseObject(reqBodyStr); |
||||
Long orderId = jsonObject.getLong("orderId"); |
||||
Integer openIdType = jsonObject.getInteger("openIdType"); // openId类型 1:小程序 2:公众号
|
||||
String openId = jsonObject.getString("openId"); // openId
|
||||
if (orderId == null || StringUtils.isBlank(openId)) { |
||||
log.error("orderToPay error!", "参数错误"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
// 订单
|
||||
HighOrder order = highOrderService.getOrderById(jsonObject.getLong("orderId")); |
||||
|
||||
if (order == null) { |
||||
log.error("orderToPay error!", "未找到订单信息"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息"); |
||||
} |
||||
|
||||
// 订单状态 : 订单支付状态 : 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
|
||||
if (order.getOrderStatus() != 1) { |
||||
log.error("orderToPayByWx error!", "无法支付,订单不处于待支付状态"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态"); |
||||
} |
||||
|
||||
Map<String,Object> map = new HashMap<>(); |
||||
map.put("orderNo", order.getOrderNo()); |
||||
map.put("payPrice", order.getPayRealPrice()); |
||||
if (order.getHighChildOrderList().get(0).getGoodsType() == 4) { |
||||
map.put("orderScene", "KFC_ORDER"); |
||||
} else if (order.getHighChildOrderList().get(0).getGoodsType() == 9) { |
||||
map.put("orderScene", "STARBUCKS_ORDER"); |
||||
} |
||||
|
||||
// 肯德基订单 星巴克订单
|
||||
map.put("body", "购买第三方产品"); |
||||
map.put("subject","购买第三方产品"); |
||||
|
||||
//微信支付
|
||||
String nonce_str = MD5Util.MD5Encode(String.valueOf(ThreadLocalRandom.current().nextInt(10000)), "UTF-8"); |
||||
int total_fee = MathUtils.objectConvertBigDecimal(map.get("payPrice")).multiply(new BigDecimal("100")).intValue(); |
||||
WeChatPayReqInfo weChatPayReqInfo = new WeChatPayReqInfo(); |
||||
weChatPayReqInfo.setAppid(SysConst.getSysConfig().getWxMchAppId()); //公众号id
|
||||
weChatPayReqInfo.setMch_id(SysConst.getSysConfig().getWxMchId()); //商户号
|
||||
if (openIdType != null && openIdType.equals(2)) { |
||||
weChatPayReqInfo.setSub_appid("wxa075e8509802f826"); //商户号公众号
|
||||
} else { |
||||
weChatPayReqInfo.setSub_appid(SysConst.getSysConfig().getWxSubAppId());//小程序
|
||||
} |
||||
weChatPayReqInfo.setSub_mch_id("1614670195"); |
||||
weChatPayReqInfo.setSub_openid(openId); |
||||
weChatPayReqInfo.setNonce_str(nonce_str); //随机字符串
|
||||
weChatPayReqInfo.setBody(map.get("body").toString()); //商品描述
|
||||
weChatPayReqInfo.setOut_trade_no(map.get("orderNo").toString()); //商户订单号
|
||||
weChatPayReqInfo.setTotal_fee(total_fee); //总金额
|
||||
weChatPayReqInfo.setSpbill_create_ip("139.159.177.244"); //终端ip
|
||||
weChatPayReqInfo.setNotify_url(SysConst.getSysConfig().getNotifyUrl()); //通知url
|
||||
weChatPayReqInfo.setTrade_type("JSAPI"); //交易类型
|
||||
weChatPayReqInfo.setAttach(map.get("orderScene").toString()); |
||||
weChatPayReqInfo.setProfit_sharing("N"); |
||||
//附加数据,区分订单类型
|
||||
Map<String,String> payMap = new HashMap<>(); |
||||
|
||||
payMap.put("app_id", weChatPayReqInfo.getSub_appid()); |
||||
payMap.put("api_key",SysConst.getSysConfig().getWxApiKey()); |
||||
payMap.put("unified_order_url",SysConst.getSysConfig().getWxUnifiedOrderUrl()); |
||||
SortedMap<Object, Object> sortedMap = wechatPayUtil.goWechatPay(weChatPayReqInfo,payMap); |
||||
return ResponseMsgUtil.success(sortedMap); |
||||
} catch (Exception e) { |
||||
log.error("orderToPay error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/hltUnionCardPay",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "工会卡支付") |
||||
public ResponseData hltUnionCardPay(@RequestBody JSONObject body, HttpServletRequest request) { |
||||
try { |
||||
// 用户
|
||||
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); |
||||
|
||||
if (body == null |
||||
|| body.getLong("orderId") == null |
||||
|| StringUtils.isBlank(body.getString("password")) |
||||
|| StringUtils.isBlank(body.getString("cardNo")) |
||||
) { |
||||
log.error("orderToPay error!", "参数错误"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
// 查询用户与卡号的关系
|
||||
HighUserCard userCard = highUserCardService.getDetailByUserCardNo(userInfoModel.getHighUser().getId(), body.getString("cardNo")); |
||||
if (userCard == null) { |
||||
log.error("hltUnionCardPay() ERROR", "未绑定卡号"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未绑定卡号"); |
||||
} |
||||
|
||||
// 订单
|
||||
HighOrder order = highOrderService.getOrderById(body.getLong("orderId")); |
||||
|
||||
if (order == null) { |
||||
log.error("hltUnionCardPay error!", "未找到订单信息"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息"); |
||||
} |
||||
|
||||
// 订单状态 : 订单支付状态 : 1.待支付 2.已支付 3.已完成 4.已取消 5.已退款
|
||||
if (order.getOrderStatus() != 1) { |
||||
log.error("hltUnionCardPay error!", "无法支付,订单不处于待支付状态"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态"); |
||||
} |
||||
|
||||
// 查询用户支付密码
|
||||
HighUserPayPassword userPayPassword = highUserPayPasswordService.getDetailByUser(order.getMemId()); |
||||
|
||||
if (userPayPassword == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_SET_USER_PAY_PWD, ""); |
||||
} |
||||
if (StringUtils.isBlank(body.getString("password"))) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_ENTER_USER_PAY_PWD, ""); |
||||
} |
||||
// 校验支付密码
|
||||
if (!AESEncodeUtil.aesEncrypt(body.getString("password")).equals(userPayPassword.getPassword())) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.USER_PAY_PWD_ERROR, ""); |
||||
} |
||||
|
||||
highOrderService.hltUnionCardPayByThirdProduct(userCard, order.getId()); |
||||
|
||||
return ResponseMsgUtil.success(order); |
||||
} catch (Exception e) { |
||||
log.error("hltUnionCardPay error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/orderToUnionPay",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "订单支付发起银联支付") |
||||
public ResponseData orderToUnionPay(@RequestBody String reqBodyStr,HttpServletRequest request) { |
||||
try { |
||||
// 用户
|
||||
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); |
||||
|
||||
if (StringUtils.isBlank(reqBodyStr)) { |
||||
log.error("orderToPay error!", "参数错误"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
JSONObject jsonObject = JSONObject.parseObject(reqBodyStr); |
||||
Long orderId = jsonObject.getLong("orderId"); |
||||
|
||||
if (orderId == null) { |
||||
log.error("orderToPay error!", "参数错误"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
// 订单
|
||||
HighOrder order = highOrderService.getOrderById(orderId); |
||||
if (order == null) { |
||||
log.error("hltUnionCardPay error!", "未找到订单信息"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息"); |
||||
} |
||||
|
||||
// 订单状态 : 订单支付状态 : 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
|
||||
if (order.getOrderStatus() != 1) { |
||||
log.error("hltUnionCardPay error!", "无法支付,订单不处于待支付状态"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态"); |
||||
} |
||||
|
||||
return ResponseMsgUtil.success(unionPayConfig.upPreOrder(UnionPayConfig.MER_ID2, UnionPayConfig.TERM_ID2, order.getOrderNo(), order.getPayRealPrice(), "购买第三方产品", CommonSysConst.getSysConfig().getUnionPayNotifyUrl(), request)); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("orderToPay error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,72 @@ |
||||
package com.hai.schedule; |
||||
|
||||
import com.alibaba.fastjson.JSONArray; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hai.config.QianZhuConfig; |
||||
import com.hai.entity.ApiStarbucksProducts; |
||||
import com.hai.service.ApiProductService; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.scheduling.annotation.Scheduled; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.Date; |
||||
|
||||
@Configuration |
||||
public class ApiThirdProductSchedule { |
||||
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ApiThirdProductSchedule.class); |
||||
|
||||
@Resource |
||||
private ApiProductService apiProductService; |
||||
|
||||
|
||||
@Scheduled(cron = "0 0 1 * * ?") // 获取星巴克产品 每日凌晨1点执行一次
|
||||
public void getStarbucksProducts() throws Exception { |
||||
JSONObject jsonObject = QianZhuConfig.getStarbucksProducts(1 , 200); |
||||
|
||||
JSONObject object = jsonObject.getJSONObject("data"); |
||||
JSONArray array = object.getJSONArray("items"); |
||||
for (Object data : array) { |
||||
JSONObject dataObject = (JSONObject) data; |
||||
|
||||
ApiStarbucksProducts starbucksProducts = apiProductService.findStarbucksProductsByGoodsId(dataObject.getLong("id")); |
||||
|
||||
if (dataObject.getInteger("shelfStatus") == 5) { |
||||
if (starbucksProducts == null) { |
||||
starbucksProducts = new ApiStarbucksProducts(); |
||||
} |
||||
starbucksProducts.setCategoryName(dataObject.getString("categoryName")); |
||||
starbucksProducts.setCream(dataObject.getString("cream")); |
||||
starbucksProducts.setCupSize(dataObject.getString("cupSize")); |
||||
starbucksProducts.setDefaultImage(dataObject.getString("defaultImage")); |
||||
starbucksProducts.setDes(dataObject.getString("des")); |
||||
starbucksProducts.setEspresso(dataObject.getString("espresso")); |
||||
starbucksProducts.setMarketGrandePrice(dataObject.getBigDecimal("marketGrandePrice")); |
||||
starbucksProducts.setMarketTallPrice(dataObject.getBigDecimal("marketTallPrice")); |
||||
starbucksProducts.setMarketVentiPrice(dataObject.getBigDecimal("marketVentiPrice")); |
||||
starbucksProducts.setSalesGrandePrice(dataObject.getBigDecimal("salesGrandePrice")); |
||||
starbucksProducts.setSalesTallPrice(dataObject.getBigDecimal("salesTallPrice")); |
||||
starbucksProducts.setSalesVentiPrice(dataObject.getBigDecimal("salesVentiPrice")); |
||||
starbucksProducts.setMilk(dataObject.getString("milk")); |
||||
starbucksProducts.setMilkBubble(dataObject.getString("milkBubble")); |
||||
starbucksProducts.setName(dataObject.getString("name")); |
||||
starbucksProducts.setTemperature(dataObject.getString("temperature")); |
||||
if (starbucksProducts.getId() == null) { |
||||
starbucksProducts.setCreateTime(new Date()); |
||||
starbucksProducts.setOperatorId(9999L); |
||||
starbucksProducts.setOperatorName("系统生成"); |
||||
starbucksProducts.setStatus(100); |
||||
starbucksProducts.setGoodsId(dataObject.getLong("id")); |
||||
apiProductService.insertStarbucksProducts(starbucksProducts); |
||||
} else { |
||||
starbucksProducts.setUpdateTime(new Date()); |
||||
apiProductService.updateStarbucksProducts(starbucksProducts); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,49 @@ |
||||
package com.hai.enum_type; |
||||
|
||||
import java.util.Objects; |
||||
|
||||
/** |
||||
* @serviceName ApiProductTypeEnum.java |
||||
* @author Sum1Dream |
||||
* @version 1.0.0 |
||||
* @Description // 产品类型
|
||||
* @createTime 17:06 2022/7/8 |
||||
**/ |
||||
public enum ApiProductTypeEnum { |
||||
type1(1, "星巴克"), |
||||
type2(2, "肯德基"), |
||||
type3(3, "第三方产品") |
||||
; |
||||
|
||||
private Integer type; |
||||
|
||||
private String name; |
||||
|
||||
ApiProductTypeEnum(int type, String name) { |
||||
this.type = type; |
||||
this.name = name; |
||||
} |
||||
|
||||
public static String getNameByType(Integer type) { |
||||
for (ApiProductTypeEnum ele : values()) { |
||||
if(Objects.equals(type,ele.getType())) return ele.getName(); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public Integer getType() { |
||||
return type; |
||||
} |
||||
|
||||
public void setType(Integer type) { |
||||
this.type = type; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
} |
@ -0,0 +1,77 @@ |
||||
package com.hai.model; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hai.entity.HighOrder; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
public class ThirdPartyModel extends HighOrder { |
||||
|
||||
// 取餐码
|
||||
private String code; |
||||
|
||||
// 第三方订单状态
|
||||
private Integer thirdOrderStatus; |
||||
|
||||
// 就餐方式
|
||||
private Integer eatType; |
||||
|
||||
// 下单手机备注
|
||||
private String kfcOrderMobileRemark; |
||||
|
||||
// 取餐码
|
||||
private List<Map<String, Object>> list; |
||||
|
||||
// 第三方内容
|
||||
private JSONObject object; |
||||
|
||||
public String getCode() { |
||||
return code; |
||||
} |
||||
|
||||
public void setCode(String code) { |
||||
this.code = code; |
||||
} |
||||
|
||||
public Integer getThirdOrderStatus() { |
||||
return thirdOrderStatus; |
||||
} |
||||
|
||||
public void setThirdOrderStatus(Integer thirdOrderStatus) { |
||||
this.thirdOrderStatus = thirdOrderStatus; |
||||
} |
||||
|
||||
|
||||
public Integer getEatType() { |
||||
return eatType; |
||||
} |
||||
|
||||
public void setEatType(Integer eatType) { |
||||
this.eatType = eatType; |
||||
} |
||||
|
||||
public String getKfcOrderMobileRemark() { |
||||
return kfcOrderMobileRemark; |
||||
} |
||||
|
||||
public void setKfcOrderMobileRemark(String kfcOrderMobileRemark) { |
||||
this.kfcOrderMobileRemark = kfcOrderMobileRemark; |
||||
} |
||||
|
||||
public List<Map<String, Object>> getList() { |
||||
return list; |
||||
} |
||||
|
||||
public void setList(List<Map<String, Object>> list) { |
||||
this.list = list; |
||||
} |
||||
|
||||
public JSONObject getObject() { |
||||
return object; |
||||
} |
||||
|
||||
public void setObject(JSONObject object) { |
||||
this.object = object; |
||||
} |
||||
} |
@ -0,0 +1,57 @@ |
||||
package com.hai.service; |
||||
|
||||
import com.hai.entity.ApiMemberProduct; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @serviceName ApiMemberProductService.java |
||||
* @author Sum1Dream |
||||
* @version 1.0.0 |
||||
* @Description // 会员产品接口
|
||||
* @createTime 16:12 2022/7/11 |
||||
**/ |
||||
public interface ApiMemberProductService { |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @name insertApiMemberProduct.java |
||||
* @Description // 新增会员产品
|
||||
* @Date 14:55 2022/6/7 |
||||
* @Param [com.alibaba.fastjson.JSONObject] |
||||
* @return void |
||||
*/ |
||||
void insertApiMemberProduct(ApiMemberProduct ApiMemberProduct); |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @name updateApiMemberProduct.java |
||||
* @Description // 修改会员产品
|
||||
* @Date 14:56 2022/6/7 |
||||
* @Param [com.alibaba.fastjson.JSONObject] |
||||
* @return void |
||||
*/ |
||||
void updateApiMemberProduct(ApiMemberProduct ApiMemberProduct); |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @name getListApiMemberProduct.java |
||||
* @Description // 查询会员产品
|
||||
* @Date 14:57 2022/6/7 |
||||
* @Param [java.util.Map<java.lang.String,java.lang.Object>] |
||||
* @return java.util.List<com.hai.entity.ApiMemberProduct> |
||||
*/ |
||||
List<ApiMemberProduct> getListApiMemberProduct(Map<String, Object> map); |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @name findById.java |
||||
* @Description // 根据id 查询会员产品
|
||||
* @Date 15:24 2022/6/7 |
||||
* @Param [java.lang.Long] |
||||
* @return com.hai.entity.ApiMemberProduct |
||||
*/ |
||||
ApiMemberProduct findById(Long id); |
||||
|
||||
} |
@ -0,0 +1,52 @@ |
||||
package com.hai.service.impl; |
||||
|
||||
import com.hai.dao.ApiMemberProductMapper; |
||||
import com.hai.entity.ApiMemberProduct; |
||||
import com.hai.entity.ApiMemberProductExample; |
||||
import com.hai.service.ApiMemberProductService; |
||||
import org.apache.commons.collections4.MapUtils; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@Service("apiMemberProductService") |
||||
public class ApiMemberProductServiceImpl implements ApiMemberProductService { |
||||
|
||||
@Resource |
||||
private ApiMemberProductMapper apiMemberProductMapper; |
||||
|
||||
@Override |
||||
public void insertApiMemberProduct(ApiMemberProduct apiMemberProduct) { |
||||
apiMemberProductMapper.insert(apiMemberProduct); |
||||
} |
||||
|
||||
@Override |
||||
public void updateApiMemberProduct(ApiMemberProduct apiMemberProduct) { |
||||
apiMemberProductMapper.updateByPrimaryKeySelective(apiMemberProduct); |
||||
} |
||||
|
||||
@Override |
||||
public List<ApiMemberProduct> getListApiMemberProduct(Map<String, Object> map) { |
||||
ApiMemberProductExample example = new ApiMemberProductExample(); |
||||
ApiMemberProductExample.Criteria criteria = example.createCriteria(); |
||||
|
||||
if (MapUtils.getInteger(map , "typeId") != null) { |
||||
criteria.andTypeIdEqualTo(MapUtils.getInteger(map , "typeId")); |
||||
} |
||||
if (MapUtils.getInteger(map , "brandId") != null) { |
||||
criteria.andBrandIdEqualTo(MapUtils.getInteger(map , "brandId")); |
||||
} |
||||
if (MapUtils.getString(map , "name") != null) { |
||||
criteria.andNameLike("%" + MapUtils.getString(map , "name") + "%"); |
||||
} |
||||
example.setOrderByClause("brand_id ASC , sort ASC"); |
||||
return apiMemberProductMapper.selectByExample(example); |
||||
} |
||||
|
||||
@Override |
||||
public ApiMemberProduct findById(Long id) { |
||||
return apiMemberProductMapper.selectByPrimaryKey(id); |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,61 @@ |
||||
package com.hai.service.pay.impl; |
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hai.config.QianZhuConfig; |
||||
import com.hai.dao.HighGasOrderPushMapper; |
||||
import com.hai.entity.HighChildOrder; |
||||
import com.hai.entity.HighGasOrderPush; |
||||
import com.hai.entity.HighOrder; |
||||
import com.hai.enum_type.OrderPushType; |
||||
import com.hai.service.HighOrderService; |
||||
import com.hai.service.pay.PayService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.math.BigDecimal; |
||||
import java.util.Date; |
||||
import java.util.Map; |
||||
|
||||
@Service("starbucksOrderService") |
||||
public class StarbucksOrderServiceImpl implements PayService { |
||||
@Resource |
||||
private HighOrderService highOrderService; |
||||
|
||||
@Resource |
||||
private HighGasOrderPushMapper highGasOrderPushMapper; |
||||
@Override |
||||
public void paySuccess(Map<String, String> map, String payType) throws Exception { |
||||
if (payType.equals("Alipay")) { |
||||
return; |
||||
} |
||||
if (payType.equals("WechatPay")) { |
||||
HighOrder order = highOrderService.getOrderByOrderNo(map.get("out_trade_no")); |
||||
if (order != null && order.getOrderStatus() == 1) { |
||||
order.setPaySerialNo(map.get("transaction_id")); // 支付流水号
|
||||
order.setPayRealPrice(new BigDecimal(map.get("total_fee")).divide(new BigDecimal("100"))); // 实付金额
|
||||
order.setPayTime(new Date()); // 支付时间
|
||||
order.setPayModel(2); // 支付模式:1 金币,2 第三方平台,3 混合
|
||||
order.setPayType(2); // 支付方式: 1:支付宝 2:微信 3:金币
|
||||
order.setOrderStatus(2); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消
|
||||
|
||||
for (HighChildOrder childOrder : order.getHighChildOrderList()) { |
||||
childOrder.setChildOrdeStatus(2); // 子订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消
|
||||
} |
||||
highOrderService.updateOrder(order); |
||||
|
||||
// 支付给千猪
|
||||
JSONObject object = QianZhuConfig.starbucksOrdersPay(order.getOrderNo()); |
||||
|
||||
// 推送订单记录
|
||||
HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); |
||||
highGasOrderPush.setType(OrderPushType.type3.getType()); |
||||
highGasOrderPush.setOrderNo(order.getOrderNo()); |
||||
highGasOrderPush.setCreateTime(new Date()); |
||||
highGasOrderPush.setRequestContent(order.getOrderNo()); |
||||
highGasOrderPush.setReturnContent(object.toJSONString()); |
||||
highGasOrderPushMapper.insert(highGasOrderPush); |
||||
} |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue