Authored by bblu

会员日签到

... ... @@ -73,6 +73,29 @@ public class SendCouponHelper {
return result;
}
/**
* 发送有货币
*
* @param uid
* @param num
* @return
*/
public boolean sendYOHOBi(int uid, int num, int type) {
YohoCoinRecordReq req = buildYohoCoinCostReq(uid, num, type);
final String serviceName = "users.addRecord";
boolean result = false;
try {
log.info("BrandActivityServiceImpl sendYOHOBi req------ is {}", req);
CommonRspBO rspBO = serviceCaller.call(serviceName, req, CommonRspBO.class);
if (rspBO != null && rspBO.getCode() == 200) {
result = true;
}
} catch (Exception e) {
log.warn("in method sendYOHOBIEvent ,invoke {} occurs error,detail is {}", serviceName, e);
}
return result;
}
// 构造参数
private YohoCoinRecordReq buildYohoCoinCostReq(int uid, int num) {
YohoCoinRecordReq req = new YohoCoinRecordReq();
... ... @@ -93,4 +116,26 @@ public class SendCouponHelper {
req.setHistory(yohoCoinLogReqBO);
return req;
}
// 构造参数
private YohoCoinRecordReq buildYohoCoinCostReq(int uid, int num, int type) {
YohoCoinRecordReq req = new YohoCoinRecordReq();
YohoCoinCostReqBO yohoCoinCostReq = new YohoCoinCostReqBO();
yohoCoinCostReq.setUid(uid);
yohoCoinCostReq.setNum(num);
yohoCoinCostReq.setType(Byte.valueOf(String.valueOf(type)));// 抽奖送币
yohoCoinCostReq.setParams("{}");
yohoCoinCostReq.setOrderCode("0");
req.setCost(yohoCoinCostReq);
YohoCoinLogReqBO yohoCoinLogReqBO = new YohoCoinLogReqBO();
yohoCoinLogReqBO.setUid(uid);
yohoCoinLogReqBO.setChangeNum(Short.valueOf(String.valueOf(num)));
yohoCoinLogReqBO.setChangeType(Byte.valueOf(String.valueOf(type)));
yohoCoinLogReqBO.setChangeParams("{}");
req.setHistory(yohoCoinLogReqBO);
return req;
}
}
... ...
package com.yoho.activity.controller;
import com.yoho.activity.common.ApiResponse;
import com.yoho.activity.service.IUserdaySigninService;
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.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* 会员日,签到
*/
@Controller
@RequestMapping("/UserdaySigninController")
public class UserdaySigninController {
private static final Logger log = LoggerFactory.getLogger(UserdaySigninController.class);
@Autowired
IUserdaySigninService userdaySigninService;
@RequestMapping("/signin")
@ResponseBody
public ApiResponse signin(int uid) throws Exception {
log.debug("enter signin. param uid={}", uid);
userdaySigninService.signin(uid);
return new ApiResponse(new Object());
}
}
... ...
package com.yoho.activity.service;
/**
* 会员日,签到
*/
public interface IUserdaySigninService {
void signin(int uid) throws Exception;
}
... ...
package com.yoho.activity.service.impl;
import com.yoho.activity.common.helper.SendCouponHelper;
import com.yoho.activity.service.IUserdaySigninService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 会员日,签到
*/
@Service
public class UserdaySigninServiceImpl implements IUserdaySigninService {
private static final Logger log = LoggerFactory.getLogger(UserdaySigninServiceImpl.class);
@Autowired
private SendCouponHelper sendCouponHelper;
@Override
public void signin(int uid) throws Exception {
log.info("enter signin. param uid={}", uid);
// (1)校验uid
if (1 > uid) {
throw new Exception("参数不合法");
}
// (2)发送有货币,完成签到
sendCouponHelper.sendYOHOBi(uid, 100, 5);
}
}
... ...