|
|
@ -4,7 +4,9 @@ import cc.hiver.core.common.constant.CommonConstant; |
|
|
import cc.hiver.core.common.constant.WorkerConstant; |
|
|
import cc.hiver.core.common.constant.WorkerConstant; |
|
|
import cc.hiver.core.common.utils.BeanUtils; |
|
|
import cc.hiver.core.common.utils.BeanUtils; |
|
|
import cc.hiver.core.common.utils.ResultUtil; |
|
|
import cc.hiver.core.common.utils.ResultUtil; |
|
|
|
|
|
import cc.hiver.core.common.utils.SecurityUtil; |
|
|
import cc.hiver.core.common.vo.Result; |
|
|
import cc.hiver.core.common.vo.Result; |
|
|
|
|
|
import cc.hiver.core.entity.User; |
|
|
import cc.hiver.core.entity.Worker; |
|
|
import cc.hiver.core.entity.Worker; |
|
|
import cc.hiver.core.service.WorkerService; |
|
|
import cc.hiver.core.service.WorkerService; |
|
|
import cc.hiver.core.vo.WorkerAppVO; |
|
|
import cc.hiver.core.vo.WorkerAppVO; |
|
|
@ -57,6 +59,9 @@ public class WorkerController { |
|
|
@Autowired |
|
|
@Autowired |
|
|
private WorkerRelaPriceMapper workerRelaPriceMapper; |
|
|
private WorkerRelaPriceMapper workerRelaPriceMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private SecurityUtil securityUtil; |
|
|
|
|
|
|
|
|
@RequestMapping(value = "/getByCondition", method = RequestMethod.POST) |
|
|
@RequestMapping(value = "/getByCondition", method = RequestMethod.POST) |
|
|
@ApiOperation(value = "多条件分页获取订单列表") |
|
|
@ApiOperation(value = "多条件分页获取订单列表") |
|
|
public Result<Page<Worker>> getByCondition(@RequestBody WorkerQueryVO worker) { |
|
|
public Result<Page<Worker>> getByCondition(@RequestBody WorkerQueryVO worker) { |
|
|
@ -91,33 +96,32 @@ public class WorkerController { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@RequestMapping(value = "/admin/add", method = RequestMethod.POST) |
|
|
@RequestMapping(value = "/admin/add", method = RequestMethod.POST) |
|
|
@ApiOperation(value = "创建配送员") |
|
|
@ApiOperation(value = "创建配送员或切换校区") |
|
|
public Result add(@Valid Worker u) { |
|
|
public Result<Worker> add(@Valid Worker u) { |
|
|
|
|
|
final User user = securityUtil.getCurrUser(); |
|
|
// 添加商圈名称
|
|
|
Worker worker = workerService.findByUserId(user.getId()); |
|
|
if (StrUtil.isNotBlank(u.getRegion())) { |
|
|
if(worker != null){ |
|
|
ShopArea d = shopAreaService.get(u.getRegion()); |
|
|
if(u.getRegion().equals(worker.getRegion())){ |
|
|
if (d != null) { |
|
|
return new ResultUtil<Worker>().setData(worker); |
|
|
u.setRegionTitle(d.getTitle()); |
|
|
|
|
|
} |
|
|
|
|
|
}else{ |
|
|
}else{ |
|
|
u.setRegion(null); |
|
|
worker.setRegion(u.getRegion()); |
|
|
u.setRegionTitle(""); |
|
|
workerService.update(worker); |
|
|
|
|
|
return new ResultUtil<Worker>().setData(worker); |
|
|
} |
|
|
} |
|
|
//更新充值记录
|
|
|
}else{ |
|
|
Recharge recharge = new Recharge(); |
|
|
if(u.getIsChangeArea() != null && u.getIsChangeArea() == 0){ |
|
|
|
|
|
return new ResultUtil<Worker>().setData(worker); |
|
|
recharge.setRechargeName(u.getWorkerName()); |
|
|
}else{ |
|
|
recharge.setRechargeWorkerId(u.getWorkerId()); |
|
|
u.setWorkerName(user.getNickname()); |
|
|
recharge.setMobile(u.getMobile()); |
|
|
u.setUserId(user.getId()); |
|
|
|
|
|
u.setAvgTime(BigDecimal.valueOf(30)); |
|
|
rechargeService.save(recharge); |
|
|
u.setMobile(user.getMobile()); |
|
|
|
|
|
u.setIsOnLine(CommonConstant.OFF_LINE); |
|
|
//更新余额,重置当次应缴
|
|
|
u.setScore(BigDecimal.valueOf(5)); |
|
|
u.setIsOnLine(CommonConstant.ON_LINE); |
|
|
|
|
|
workerService.save(u); |
|
|
workerService.save(u); |
|
|
|
|
|
return new ResultUtil<Worker>().setData(u); |
|
|
return ResultUtil.success("创建成功"); |
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@RequestMapping(value = "/admin/edit", method = RequestMethod.POST) |
|
|
@RequestMapping(value = "/admin/edit", method = RequestMethod.POST) |
|
|
|