|  |  |  | 
|---|
|  |  |  | package com.matrix.system.shopXcx.api.action; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.matrix.system.hive.bean.SysVipInfo; | 
|---|
|  |  |  | import com.matrix.component.redis.RedisUserLoginUtils; | 
|---|
|  |  |  | import com.matrix.component.tools.WxUtils; | 
|---|
|  |  |  | import com.matrix.core.pojo.AjaxResult; | 
|---|
|  |  |  | import com.matrix.core.tools.LogUtil; | 
|---|
|  |  |  | import com.matrix.biz.bean.BizUser; | 
|---|
|  |  |  | import com.matrix.system.common.bean.BusParameterSettings; | 
|---|
|  |  |  | import com.matrix.system.common.bean.CustomerDataDictionary; | 
|---|
|  |  |  | import com.matrix.system.common.constance.AppConstance; | 
|---|
|  |  |  | import com.matrix.system.common.dao.BusParameterSettingsDao; | 
|---|
|  |  |  | import com.matrix.system.common.dao.CustomerDataDictionaryDao; | 
|---|
|  |  |  | import com.matrix.component.redis.RedisUserLoginUtils; | 
|---|
|  |  |  | import com.matrix.system.common.constance.AppConstance; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.matrix.system.shopXcx.api.service.WxShopRefundRecordService; | 
|---|
|  |  |  | import com.matrix.system.shopXcx.api.tools.SMSTools; | 
|---|
|  |  |  | import com.matrix.system.shopXcx.bean.ShopDeliveryInfo; | 
|---|
|  |  |  | import com.matrix.system.shopXcx.bean.ShopOrder; | 
|---|
|  |  |  | import com.matrix.system.shopXcx.bean.ShopRefundRecord; | 
|---|
|  |  |  | import com.matrix.system.shopXcx.dao.ShopDeliveryInfoDao; | 
|---|
|  |  |  | import com.matrix.system.shopXcx.dao.ShopOrderDao; | 
|---|
|  |  |  | import com.matrix.system.shopXcx.dao.ShopRefundRecordDao; | 
|---|
|  |  |  | import com.matrix.component.tools.WxUtils; | 
|---|
|  |  |  | import com.matrix.system.shopXcx.api.service.WxShopRefundRecordService; | 
|---|
|  |  |  | import com.matrix.system.shopXcx.api.tools.SMSTools; | 
|---|
|  |  |  | import org.apache.commons.collections.CollectionUtils; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Controller; | 
|---|
|  |  |  | 
|---|
|  |  |  | @PostMapping(value = "/saveRefundRecord") | 
|---|
|  |  |  | public @ResponseBody | 
|---|
|  |  |  | AjaxResult saveRefundRecord(@RequestBody ShopRefundRecord refundRecord) { | 
|---|
|  |  |  | BizUser loginUser = redisUserLoginUtils.getLoginUser(BizUser.class); | 
|---|
|  |  |  | SysVipInfo loginUser = redisUserLoginUtils.getLoginUser(SysVipInfo.class); | 
|---|
|  |  |  | refundRecord.setCreateBy(loginUser.getOpenId()); | 
|---|
|  |  |  | refundRecord.setUpdateBy(loginUser.getOpenId()); | 
|---|
|  |  |  | refundRecord.setUserId(loginUser.getOpenId()); | 
|---|
|  |  |  | refundRecord.setUserId(loginUser.getId()); | 
|---|
|  |  |  | refundRecord.setCompanyId(loginUser.getCompanyId()); | 
|---|
|  |  |  | refundRecord.setAuditStatus(AppConstance.REFUND_NOT_AUDITED); | 
|---|
|  |  |  | refundRecord.setRefundStatus(AppConstance.REFUND_PROCESSING); | 
|---|
|  |  |  | 
|---|
|  |  |  | refundRecord.setApplyTime(new Date()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ShopRefundRecord record = new ShopRefundRecord(); | 
|---|
|  |  |  | record.setUserId(loginUser.getOpenId()); | 
|---|
|  |  |  | record.setUserId(loginUser.getId()); | 
|---|
|  |  |  | record.setOrderId(refundRecord.getOrderId()); | 
|---|
|  |  |  | List<ShopRefundRecord> shopRefundRecords = refundRecordDao.selectByModel(record); | 
|---|
|  |  |  | if(CollectionUtils.isNotEmpty(shopRefundRecords)){ | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(flag){ | 
|---|
|  |  |  | ShopRefundRecord fundRecord = refundRecordDao.selectById(shopRecord.getId()); | 
|---|
|  |  |  | refundRecordService.sendRefundInfoToUser(fundRecord); | 
|---|
|  |  |  | refundRecordService.updateGroupBuyStatus(orderId.longValue()); | 
|---|
|  |  |  | return new AjaxResult(AjaxResult.STATUS_SUCCESS, "退款成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | modifyMap.put("id", orderId); | 
|---|
|  |  |  | modifyMap.put("orderStatus", ShopOrder.ORDER_STATUS_APPLY_MONEYBACK); | 
|---|
|  |  |  | shopOrderDao.updateByMap(modifyMap); | 
|---|
|  |  |  | //从数据字典获取需要发送的手机号码和短信提醒内容 | 
|---|
|  |  |  | BusParameterSettings busParameterSetting1 =busParameterSettingsDao.selectCompanyParamByCode("MSG_ALERT_CONTENT_REFUND",17L); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String msg = busParameterSetting1.getParamValue(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //TODO 写死微商城17L公司id | 
|---|
|  |  |  | BusParameterSettings busParameterSetting= busParameterSettingsDao.selectCompanyParamByCode("MSG_ALERT_MOBILE",17L); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String phons = busParameterSetting.getParamValue(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | phons.replace(',',','); | 
|---|
|  |  |  | List<String> result = Arrays.asList(phons.split(",")); | 
|---|
|  |  |  | if(CollectionUtils.isNotEmpty(result)){ | 
|---|
|  |  |  | for(String phon : result){ | 
|---|
|  |  |  | smsTools.sendMsg(phon, msg + "退订回T" ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return new AjaxResult(AjaxResult.STATUS_SUCCESS, "保存成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | @PostMapping("/findRefundRecord") | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | public AjaxResult getRefundRecordByUserId(@RequestBody ShopRefundRecord refundRecord) { | 
|---|
|  |  |  | BizUser loginUser = redisUserLoginUtils.getLoginUser(BizUser.class); | 
|---|
|  |  |  | String userId = loginUser.getOpenId(); | 
|---|
|  |  |  | refundRecord.setUserId(userId); | 
|---|
|  |  |  | SysVipInfo loginUser = redisUserLoginUtils.getLoginUser(SysVipInfo.class); | 
|---|
|  |  |  | refundRecord.setUserId(loginUser.getId()); | 
|---|
|  |  |  | List<ShopRefundRecord> list = refundRecordDao.selectByRefundUserId(refundRecord); | 
|---|
|  |  |  | AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, list, list.size()); | 
|---|
|  |  |  | return result; | 
|---|