同步二维码

master
wangweijia 6 years ago
parent b7ce416b10
commit de20a76269

@ -1,10 +1,15 @@
package com.kiisoo.ic.synchronous.controller; package com.kiisoo.ic.synchronous.controller;
import com.kiisoo.ic.common.BaseController;
import com.kiisoo.ic.synchronous.service.PromotionCodeService; import com.kiisoo.ic.synchronous.service.PromotionCodeService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Map;
/** /**
* 广 * 广
@ -12,14 +17,19 @@ import org.springframework.web.bind.annotation.RequestMapping;
@Controller @Controller
@RequestMapping("/promotion") @RequestMapping("/promotion")
@Slf4j @Slf4j
public class PromotionCodeController { public class PromotionCodeController extends BaseController {
@Autowired @Autowired
private com.kiisoo.ic.synchronous.service.PromotionCodeService PromotionCodeService; private PromotionCodeService promotionCodeService;
//参数类型0为门店账号1为内部员工导购2为其他 /**
public void getShopPromotion(){ * 广
PromotionCodeService.getPromotion(0); */
@RequestMapping(value = "/shop",method = RequestMethod.GET)
@ResponseBody
public Map<String, Object> getShopPromotion(){
promotionCodeService.getStaffPromotion();
return data(success());
} }
public void getStaffPromotion(){} public void getStaffPromotion(){}

@ -9,6 +9,7 @@ import com.kiisoo.ic.common.utils.httpClientUtil.HttpClientUtil;
import com.kiisoo.ic.common.utils.httpClientUtil.HttpResult; import com.kiisoo.ic.common.utils.httpClientUtil.HttpResult;
import com.kiisoo.ic.employee.entity.PrivilageCpUserDO; import com.kiisoo.ic.employee.entity.PrivilageCpUserDO;
import com.kiisoo.ic.employee.mapper.PrivilageCpUserDOMapper; import com.kiisoo.ic.employee.mapper.PrivilageCpUserDOMapper;
import com.kiisoo.ic.store.bean.BsdShareCodeResponse;
import com.kiisoo.ic.store.constant.Constants; import com.kiisoo.ic.store.constant.Constants;
import com.kiisoo.ic.store.entity.PoiStore; import com.kiisoo.ic.store.entity.PoiStore;
import com.kiisoo.ic.store.entity.PoiStoreStaff; import com.kiisoo.ic.store.entity.PoiStoreStaff;
@ -18,13 +19,15 @@ import com.kiisoo.ic.store.mapper.PoiStoreDOMapper;
import com.kiisoo.ic.store.mapper.PoiStoreStaffDOMapper; import com.kiisoo.ic.store.mapper.PoiStoreStaffDOMapper;
import com.kiisoo.ic.store.mapper.PrivilageCpUserStoreDOMapper; import com.kiisoo.ic.store.mapper.PrivilageCpUserStoreDOMapper;
import com.kiisoo.ic.synchronous.entity.PromotionDO; import com.kiisoo.ic.synchronous.entity.PromotionDO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.text.SimpleDateFormat;
import java.util.List; import java.util.*;
import static com.kiisoo.ic.employee.constant.Constants.DATABASE_CP_USER_ID_KEY; import static com.kiisoo.ic.employee.constant.Constants.DATABASE_CP_USER_ID_KEY;
import static com.kiisoo.ic.store.constant.Constants.BSD_REQ_QRCODE_TYPE_STORE;
@Service @Service
public class PromotionCodeService { public class PromotionCodeService {
@ -49,9 +52,8 @@ public class PromotionCodeService {
/** /**
* *
* @param i
*/ */
public void getPromotion(int i) { public void getPromotion() {
//找到所有店铺 //找到所有店铺
List<PoiStore> shops = poiStoreDOMapper.selectList(null); List<PoiStore> shops = poiStoreDOMapper.selectList(null);
@ -59,25 +61,22 @@ public class PromotionCodeService {
List<Long> shopIds = new ArrayList<>(); List<Long> shopIds = new ArrayList<>();
shopIds.add(item.getId()); shopIds.add(item.getId());
//找到是否有推广码 //找到是否有推广码
List<StoreUserDTO> cpUserStoreDO = privilageCpUserStoreDOMapper.selectCpUserByShops(shopIds); List<StoreUserDTO> privilageCpUserDO = privilageCpUserStoreDOMapper.selectCpUserByShops(shopIds);
if(cpUserStoreDO.size() == 0){ if(privilageCpUserDO.size() > 0){
PromotionDO p = new PromotionDO(); StoreUserDTO cpUserStore = privilageCpUserDO.get(0);
p.setType("0");
p.setStoreNo(item.getCode()); String qrCodeAction = cpUserStore.getQrCodeAction();
//没有推广码则查询 if(StringUtils.isBlank(qrCodeAction)){
HttpResult data = HttpClientUtil.httpPost("http://vtest.bsd.cn/BSD_WXAPP/qyWechat/getShareQRcode?token=TOKEN", JSON.toJSONString(p),getToken()); try {
//http返回参数 qrCodeAction = getQrCodeFromBSD(cpUserStore.getCpUserId(),BSD_REQ_QRCODE_TYPE_STORE,"0",item.getCode());
if((boolean) JSONObject.parseObject(data.getMessage()).get("success")){ cpUserStore.setQrCodeAction(qrCodeAction);
String url = JSONObject.parseObject(data.getMessage()).get("data").toString(); PrivilageCpUserDO update = new PrivilageCpUserDO();
update.setId(cpUserStore.getUserId());
//排重---根据企业微信账号查询是否存在用户 update.setQrCode(qrCodeAction);
PrivilageCpUserDO privilageCpUserDO = new PrivilageCpUserDO(); privilageCpUserDOMapper.updateById(update);
privilageCpUserDO.setQrCode(url); } catch (Exception e) {
int insert = privilageCpUserDOMapper.insert(privilageCpUserDO); e.printStackTrace();
PrivilageCpUserStoreDO cpUserStore = new PrivilageCpUserStoreDO(); }
cpUserStore.setStoreId(item.getId());
cpUserStore.setCpUserId(privilageCpUserDO.getId());
privilageCpUserStoreDOMapper.insert(cpUserStore);
} }
} }
@ -86,6 +85,31 @@ public class PromotionCodeService {
}); });
} }
/**
*
* @param cpUserId
* @param type
* @param state
* @param storeNo
* @return
* @throws Exception
*/
public String getQrCodeFromBSD(String cpUserId,String type,String state,String storeNo) throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Map<String, Object> params = new HashMap<>();
params.put("userId", cpUserId);
params.put("type", type);
params.put("state", state);
params.put("storeNo", storeNo);
String message = HttpClientUtil.httpPost("http://vtest.bsd.cn/BSD_WXAPP/qyWechat/getShareQRcode?token=" + MD5FileUtil.getMD5String("BOSIDENG" + sdf.format(new Date())), JSONObject.toJSONString(params)).getMessage();
JSONObject qrCodeJson = JSONObject.parseObject(message);
BsdShareCodeResponse bsdResponse = qrCodeJson.toJavaObject(BsdShareCodeResponse.class);
if (bsdResponse.getSuccess()){
return bsdResponse.getData();
}
return null;
}
/** /**
* *

@ -190,6 +190,7 @@ public class OrganizationInit {
//排重---根据企业微信账号查询是否存在用户 //排重---根据企业微信账号查询是否存在用户
PrivilageCpUserDO privilageCpUserDO = new PrivilageCpUserDO(); PrivilageCpUserDO privilageCpUserDO = new PrivilageCpUserDO();
privilageCpUserDO.setCpUserId(v.getCustomerUserId()); privilageCpUserDO.setCpUserId(v.getCustomerUserId());
privilageCpUserDO.setStatus(1);
int insert = privilageCpUserDOMapper.insert(privilageCpUserDO); int insert = privilageCpUserDOMapper.insert(privilageCpUserDO);
PrivilageCpUserStoreDO cpUserStore = new PrivilageCpUserStoreDO(); PrivilageCpUserStoreDO cpUserStore = new PrivilageCpUserStoreDO();
cpUserStore.setStoreId(shopId); cpUserStore.setStoreId(shopId);

Loading…
Cancel
Save