Search in sources :

Example 1 with Goods

use of com.goodskill.entity.Goods in project goodsKill by techa03.

the class SeckillServiceImplTest method getInfoById.

@Test
public void getInfoById() {
    Seckill seckill = new Seckill();
    long seckillId = 1L;
    seckill.setSeckillId(seckillId);
    int goodsId = 2;
    seckill.setGoodsId(goodsId);
    when(seckillServiceInterface.getById(seckillId)).thenReturn(seckill);
    when(goodsService.getById(goodsId)).thenReturn(new Goods());
    seckillService.getInfoById(seckillId);
}
Also used : Goods(com.goodskill.entity.Goods) Seckill(com.goodskill.entity.Seckill) Test(org.junit.jupiter.api.Test)

Example 2 with Goods

use of com.goodskill.entity.Goods in project goodsKill by techa03.

the class MultiDatasourceTransactionTest method testInsert.

@Test
@Transactional
public void testInsert() {
    Goods entity = new Goods();
    entity.setName("test");
    goodsMapper.insert(entity);
    SuccessKilled su = new SuccessKilled();
    su.setUserPhone("3434");
    su.setSeckillId(1432L);
    successKilledMapper.insert(su);
    su = new SuccessKilled();
    su.setUserPhone("3435");
    su.setSeckillId(1432L);
    successKilledMapper.insert(su);
    su = new SuccessKilled();
    su.setUserPhone("3435");
    su.setSeckillId(1431L);
    successKilledMapper.insert(su);
    su = new SuccessKilled();
    su.setUserPhone("3434");
    su.setSeckillId(1431L);
    successKilledMapper.insert(su);
}
Also used : Goods(com.goodskill.entity.Goods) SuccessKilled(com.goodskill.entity.SuccessKilled) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with Goods

use of com.goodskill.entity.Goods in project goodsKill by techa03.

the class AlipayRunner method tradePrecreate.

public String tradePrecreate(long seckillId) {
    Seckill seckill = redisService.getSeckill(seckillId);
    Goods goods = goodsMapper.selectById(seckill.getGoodsId());
    // 需保证商户系统端不能重复,建议通过数据库sequence生成,
    String outTradeNo = "tradeprecreate" + System.currentTimeMillis() + (long) (Math.random() * 10000000L);
    // 1. 设置参数(全局只需设置一次)
    Factory.setOptions(getOptions());
    try {
        // 2. 发起API调用(以创建当面付收款二维码为例)
        AlipayTradePrecreateResponse response = Factory.Payment.FaceToFace().preCreate(goods.getName(), outTradeNo, String.valueOf(seckill.getPrice()));
        // 3. 处理响应或异常
        if (ResponseChecker.success(response)) {
            String finalQrcodeImagePath = String.format(qrcodeImagePath + "/qr-%s.png", response.outTradeNo);
            ZxingUtils.getQRCodeImge(response.qrCode, 256, finalQrcodeImagePath);
            log.info("支付宝当面扫调用成功!");
            return finalQrcodeImagePath.split("/")[finalQrcodeImagePath.split("/").length - 1];
        } else {
            log.error("调用失败,原因:" + response.msg + "," + response.subMsg);
        }
    } catch (Exception e) {
        log.error("调用遭遇异常,原因:" + e.getMessage());
    }
    return null;
}
Also used : AlipayTradePrecreateResponse(com.alipay.easysdk.payment.facetoface.models.AlipayTradePrecreateResponse) Goods(com.goodskill.entity.Goods) Seckill(com.goodskill.entity.Seckill)

Example 4 with Goods

use of com.goodskill.entity.Goods in project goodsKill by techa03.

the class GoodsServiceImpl method uploadGoodsPhoto.

@Override
public void uploadGoodsPhoto(long goodsId, byte[] bytes) {
    Goods goods = new Goods();
    goods.setGoodsId((int) goodsId);
    goods.setPhotoImage(bytes);
    log.info(goods.toString());
    this.updateById(goods);
}
Also used : Goods(com.goodskill.entity.Goods)

Example 5 with Goods

use of com.goodskill.entity.Goods in project goodsKill by techa03.

the class SeckillServiceImpl method getInfoById.

@Override
public SeckillInfoDTO getInfoById(Serializable seckillId) {
    SeckillInfoDTO seckillInfoDTO = new SeckillInfoDTO();
    Seckill seckill = seckillService.getById(seckillId);
    Goods goods = goodsService.getById(seckill.getGoodsId());
    BeanUtils.copyProperties(seckill, seckillInfoDTO);
    seckillInfoDTO.setGoodsName(goods.getName());
    return seckillInfoDTO;
}
Also used : Goods(com.goodskill.entity.Goods) Seckill(com.goodskill.entity.Seckill)

Aggregations

Goods (com.goodskill.entity.Goods)8 Seckill (com.goodskill.entity.Seckill)4 Test (org.junit.jupiter.api.Test)3 AlipayTradePrecreateResponse (com.alipay.easysdk.payment.facetoface.models.AlipayTradePrecreateResponse)1 GoodsService (com.goodskill.api.service.GoodsService)1 SuccessKilled (com.goodskill.entity.SuccessKilled)1 GoodsEsService (com.goodskill.es.api.GoodsEsService)1 GlobalTransactional (io.seata.spring.annotation.GlobalTransactional)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Resource (javax.annotation.Resource)1 Slf4j (lombok.extern.slf4j.Slf4j)1 DubboReference (org.apache.dubbo.config.annotation.DubboReference)1 ShardingContext (org.apache.shardingsphere.elasticjob.api.ShardingContext)1 SimpleJob (org.apache.shardingsphere.elasticjob.simple.job.SimpleJob)1 BeanUtils (org.springframework.beans.BeanUtils)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 Component (org.springframework.stereotype.Component)1 Transactional (org.springframework.transaction.annotation.Transactional)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1